<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/12/19
 * Time: 14:28
 */
class Activity_vote_topic_model extends CI_Model
{
    private $_table  = 'activity_vote_topic';
    private $_table1 = 'activity_vote_topic_option';

    public function findVoteTopicOption($voteId)
    {
        $this->db->select('activity_vote_topic.topic_id,title, type, id, option_name, count');
        $this->db->from($this->_table.' AS activity_vote_topic');
        $this->db->join($this->_table1.' AS activity_vote_topic_option', 'activity_vote_topic_option.topic_id = activity_vote_topic.topic_id', 'INNER');
        $this->db->where('activity_vote_topic.vote_id', $voteId);
        $this->db->where('activity_vote_topic.status', 1);
        $this->db->where('activity_vote_topic_option.status', 1);
        $this->db->order_by('activity_vote_topic.sort', 'ASC');
        $this->db->order_by('activity_vote_topic_option.count', 'DESC');
        return $this->db->get();
    }



}